home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Dema / betonsoldier_spdemo.exe / {app} / Shaders / KT_PostProcess_BOS.fx < prev    next >
Encoding:
Text File  |  2005-05-05  |  8.0 KB  |  267 lines

  1. //------------------------------------------------------------------------------------------------------
  2. //------------------------------------------------------------------------------------------------------
  3. //------------------------------------------------------------------------------------------------------
  4.  
  5. #include "KT_PostProcess_Common.fx"
  6.  
  7. //------------------------------------------------------------------------------------------------------
  8. //- Static parameters
  9. //------------------------------------------------------------------------------------------------------
  10.  
  11. float4 GlowThreshold;
  12.  
  13.  
  14. //------------------------------------------------------------------------------------------------------
  15. //------------------------------------------------------------------------------------------------------
  16. //------------------------------------------------------------------------------------------------------
  17. technique    HorizontalBlurSample4
  18. <
  19.     int Priority = 1;
  20.     int TechniqueIndex = 0;
  21.     int DeviceType = HWSHADER_ONLY;
  22.     int LightingType = INTEGRATED_LIGHTING;
  23.     string RenderingType = "Standard";
  24. >
  25. {
  26.     pass pass1
  27.     {
  28.         Texture  [0]        = <SourceTexture1>;
  29.         MinFilter[0]        = LINEAR;
  30.         MagFilter[0]        = LINEAR;
  31.         MipFilter[0]        = NONE; //no mipmaps.
  32.         AddressU [0]        = CLAMP;
  33.         AddressV [0]        = CLAMP;
  34.         
  35.         Texture  [1]        = <SourceTexture1>;
  36.         MinFilter[1]        = LINEAR;
  37.         MagFilter[1]        = LINEAR;
  38.         MipFilter[1]        = NONE; //no mipmaps.
  39.         AddressU [1]        = CLAMP;
  40.         AddressV [1]        = CLAMP;
  41.         
  42.         Texture  [2]        = <SourceTexture1>;
  43.         MinFilter[2]        = LINEAR;
  44.         MagFilter[2]        = LINEAR;
  45.         MipFilter[2]        = NONE; //no mipmaps.
  46.         AddressU [2]        = CLAMP;
  47.         AddressV [2]        = CLAMP;
  48.         
  49.         Texture  [3]        = <SourceTexture1>;
  50.         MinFilter[3]        = LINEAR;
  51.         MagFilter[3]        = LINEAR;
  52.         MipFilter[3]        = NONE; //no mipmaps.
  53.         AddressU [3]        = CLAMP;
  54.         AddressV [3]        = CLAMP;
  55.         
  56.         AlphaBlendEnable    = false;
  57.         AlphaTestEnable        = false;
  58.         FogEnable            = false;
  59.         
  60.         CullMode            = NONE;
  61.         ZEnable                = false;
  62.         ZWriteEnable        = false;
  63.         
  64.         VertexShader = compile vs_1_1 VSNeighbourSamplingLine();
  65.         
  66.         PixelShader = 
  67.         asm
  68.         {
  69.             ps.1.1
  70.  
  71.             def c0, 0.0f,0.0f,0.0f,1.0f 
  72.             def c1, 0.15f,0.15f,0.15f,0.15f //blur weights of outer samples
  73.             def c2, 0.35f,0.35f,0.35f,0.35f //blur weights of inner samples which may be resulting in colored blur if not equals
  74.             
  75.  
  76.             tex t0
  77.             tex t1
  78.             tex t2
  79.             tex t3
  80.  
  81.             mul r0.rgb, t0, c1 + mov r0.a, c0.a
  82.             mad r0.rgb, t1, c2, r0
  83.             mad r0.rgb, t2, c2, r0
  84.             mad r0.rgb, t3, c1, r0                                    
  85.         };
  86.     }
  87. }
  88. //------------------------------------------------------------------------------------------------------
  89. //------------------------------------------------------------------------------------------------------
  90. //------------------------------------------------------------------------------------------------------
  91. technique VerticalBlurSample4
  92. <
  93.     int Priority = 1;
  94.     int TechniqueIndex = 1;
  95.     int DeviceType = HWSHADER_ONLY;
  96.     int LightingType = INTEGRATED_LIGHTING;
  97.     string RenderingType = "Standard";
  98. >
  99. {
  100.     pass pass1
  101.     {
  102.         Texture  [0]        = <SourceTexture1>;
  103.         MinFilter[0]        = LINEAR;
  104.         MagFilter[0]        = LINEAR;
  105.         MipFilter[0]        = NONE; //no mipmaps.
  106.         AddressU [0]        = CLAMP;
  107.         AddressV [0]        = CLAMP;
  108.         
  109.         Texture  [1]        = <SourceTexture1>;
  110.         MinFilter[1]        = LINEAR;
  111.         MagFilter[1]        = LINEAR;
  112.         MipFilter[1]        = NONE; //no mipmaps.
  113.         AddressU [1]        = CLAMP;
  114.         AddressV [1]        = CLAMP;
  115.         
  116.         Texture  [2]        = <SourceTexture1>;
  117.         MinFilter[2]        = LINEAR;
  118.         MagFilter[2]        = LINEAR;
  119.         MipFilter[2]        = NONE; //no mipmaps.
  120.         AddressU [2]        = CLAMP;
  121.         AddressV [2]        = CLAMP;
  122.         
  123.         Texture  [3]        = <SourceTexture1>;
  124.         MinFilter[3]        = LINEAR;
  125.         MagFilter[3]        = LINEAR;
  126.         MipFilter[3]        = NONE; //no mipmaps.
  127.         AddressU [3]        = CLAMP;
  128.         AddressV [3]        = CLAMP;
  129.         
  130.         AlphaBlendEnable    = false;
  131.         AlphaTestEnable        = false;
  132.         FogEnable            = false;        
  133.         
  134.         CullMode            = NONE;
  135.         ZEnable                = false;
  136.         ZWriteEnable        = false;
  137.         
  138.         VertexShader = compile vs_1_1 VSNeighbourSamplingColumn();
  139.         
  140.         PixelShader = 
  141.         asm
  142.         {
  143.             ps.1.1
  144.  
  145.             def c0, 0.0f,0.0f,0.0f,1.0f                    
  146.             def c1, 0.15f,0.15f,0.15f,0.15f //blur weights of outer samples                        
  147.             def c2, 0.35f,0.35f,0.35f,0.35f //blur weights of inner samples which may be resulting in colored blur if not equals
  148.  
  149.             tex t0
  150.             tex t1
  151.             tex t2
  152.             tex t3
  153.  
  154.             mul r0.rgb, t0, c1 + mov r0.a, c0.a
  155.             mad r0.rgb, t1, c2, r0
  156.             mad r0.rgb, t2, c2, r0
  157.             mad r0.rgb, t3, c1, r0                
  158.         };
  159.     }
  160. }
  161. //------------------------------------------------------------------------------------------------------
  162. //------------------------------------------------------------------------------------------------------
  163. //------------------------------------------------------------------------------------------------------
  164. technique    GlowMapBuild
  165. <
  166.     int Priority = 1;
  167.     int TechniqueIndex = 2;
  168.     int DeviceType = HWSHADER_ONLY;
  169.     int LightingType = INTEGRATED_LIGHTING;
  170.     string RenderingType = "Standard";
  171. >
  172. {
  173.     pass pass1
  174.     {
  175.         Texture  [0]        = <SourceTexture1>;
  176.         MinFilter[0]        = LINEAR;
  177.         MagFilter[0]        = LINEAR;
  178.         MipFilter[0]        = POINT;
  179.         AddressU [0]        = CLAMP;
  180.         AddressV [0]        = CLAMP;
  181.                  
  182.         AlphaBlendEnable    = false;
  183.         AlphaTestEnable        = false;
  184.         FogEnable            = false;        
  185.         
  186.         CullMode            = NONE;
  187.         ZEnable                = false;
  188.         ZWriteEnable        = false;
  189.         
  190.         VertexShader = compile vs_1_1 VSBase();
  191.         
  192.         PixelShaderConstant[0]=<GlowThreshold>;
  193.         
  194.         PixelShader = 
  195.         asm
  196.         {
  197.             ps.1.1
  198.             
  199.             def c1, 0.30f,0.59f,0.11f,0.0f    //constantes de luminance. pour conversion de la scene en Noir & Blanc
  200.             def c2, 0.0f,0.0f,0.0f,0.0f        // zero, what we take for the glowmap where it is not supposed to glow
  201.             def c3, 0.5f,0.5f,0.5f,0.5f        // to bias the cnd level
  202.                         
  203.             tex t0
  204.  
  205.             dp3 r0.rgba, t0, c1  //conversion en N&B, j ecris aussi et surtout dans l alpha.
  206.             
  207.             sub r0.a, r0, c0        // (rendu noir et blanc - seuil glow)
  208.             add_sat r0.a, r0, c3    //  le seuil du cnd est a 0.5 en hardware, pour couper ou on veut, on biaise notre seuil
  209.             cnd r0, r0.a, t0, c2    //  et masquage avec l alpha seuil, on construit la glow map en prenant le diffuse ou zero selon le seuil.                    
  210.         };
  211.     }
  212. }
  213. //------------------------------------------------------------------------------------------------------
  214. //------------------------------------------------------------------------------------------------------
  215. //------------------------------------------------------------------------------------------------------
  216. technique    LuminanceConversion
  217. <
  218.     int Priority = 1;
  219.     int TechniqueIndex = 3;
  220.     int DeviceType = HWSHADER_ONLY;
  221.     int LightingType = INTEGRATED_LIGHTING;
  222.     string RenderingType = "Standard";
  223. >
  224. {
  225.     pass pass1
  226.     {
  227.         Texture  [0]        = <SourceTexture1>;
  228.         MinFilter[0]        = LINEAR;
  229.         MagFilter[0]        = LINEAR;
  230.         MipFilter[0]        = POINT;
  231.         AddressU [0]        = CLAMP;
  232.         AddressV [0]        = CLAMP;
  233.                  
  234.         AlphaBlendEnable    = false;
  235.         AlphaTestEnable        = false;
  236.         FogEnable            = false;        
  237.         
  238.         CullMode            = NONE;
  239.         ZEnable                = false;
  240.         ZWriteEnable        = false;
  241.         
  242.         VertexShader = compile vs_1_1 VSBase();
  243.         
  244.         PixelShader = 
  245.         asm
  246.         {
  247.             ps.1.1
  248.             
  249.             def c1, 0.30f,0.59f,0.11f,0.0f    //constantes de luminance. pour conversion de la scene en Noir & Blanc
  250.                         
  251.             tex t0
  252.  
  253.             dp3 r0.rgba, t0, c1  //conversion en N&B, j ecris aussi et surtout dans l alpha.
  254.         };
  255.     }
  256. }
  257.  
  258.  
  259. //------------------------------------------------------------------------------------------------------
  260. //------------------------------------------------------------------------------------------------------
  261. //------------------------------------------------------------------------------------------------------
  262.  
  263.  
  264. //------------------------------------------------------------------------------------------------------
  265. //------------------------------------------------------------------------------------------------------
  266. //------------------------------------------------------------------------------------------------------
  267.